package com.qf.controller;

import com.alibaba.fastjson.JSON;
import com.qf.common.R;
import com.qf.service.TeacherService;
import com.qf.service.impl.TeacherServiceImpl;
import com.qf.servlet.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/teacher")
public class TeacherController extends BaseServlet {

    private TeacherService teacherService = new TeacherServiceImpl();

    public void doInitModify(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        teacherService.initModify(request, response);
        request.getRequestDispatcher("teaInfo.jsp").forward(request, response);
    }

    public void doModify(HttpServletRequest request, HttpServletResponse response) throws IOException {
        teacherService.modify(request, response);
    }

    public void doGetTeachers(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        teacherService.getTeachers(request, response);
    }

    public void doAddTeacher(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        teacherService.add(request, response);

    }

    public void doInitAddTeacher(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        teacherService.initAddTeacher(request, response);

    }

    public void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        teacherService.delete(request, response);
      }
}